﻿namespace Homework04
{
    /// <summary>
    /// 输出10000以内质数的个数
    /// </summary>
    internal class Homework04
    {
        static void Main()
        {//设置函数
            int cout = 0;
            for (int i = 2; i <= 10000; i++)
            {
                if (IsPrime(i))
                {
                    cout++;
                }
            }
            Console.WriteLine($"10000以内质数的个数为{cout}");

        }
        static bool IsPrime(int num)
        {
            if (num <= 1) return false;
            if (num == 2) return true;
            if (num % 2 == 0) return false;
            for (int i = 3; i * i <= num; i += 2)
            {
                if (num % i == 0) return false;
            }
            return true;
        }

    }
}
